<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul th:object=${hatchetMerchant}>
							<!-- 隐藏表单 用来保存代理商id -->
							<li hidden="hidden">
								代理商id<input id="agentId" type="text" th:value="${hatchetMerchant.agentId}"/>
							</li>
							<li>
								客户编号：<input type="text" name="merchantNo"/>
							</li>
							<li>
								客户名称：<input type="text" name="merchantCnName"/>
							</li>
							<li>
								客户身份证：<input type="text" name="idCardNumber"/>
							</li>
							<li>
								代理编号：<input type="text" name="agentNo"/>
							</li>
							<li>
								代理名称：<input type="text" name="agentName"/>
							</li>
							<li>
								联系电话：<input type="text" name="pHONE"/>
							</li>
							<li>
								推荐人电话：<input type="text" name="parentPhone"/>
							</li>
							<li>
								客户级别：<select name="lEVEL" th:with="type=${@dict.getType('merchant_level')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li class="select-time">
								<label>升级时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
								<span style="color: red">升级时间仅在客户级别是黄金会员和经纪人时生效</span>
							</li>
							
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-warning" onclick="$.table.exportExcel()">
		            <i class="fa fa-download"></i> 导出
		        </a>
	        </div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
       var editFlag = [[${@permission.hasPermi('system:hatchetMerchant:edit')}]];
        /*var removeFlag = [[${@permission.hasPermi('system:hatchetMerchant:remove')}]]; */
        var level = [[${@dict.getType('merchant_level')}]];
        var prefix = ctx + "system/hatchetMerchant";
		var agentId = $("#agentId").val();
		var tableUrl = prefix + "/list";
		if(agentId !=""){
			tableUrl = prefix + "/list/"+agentId;
		}
        $(function() {
            var options = {
                url: tableUrl,
             /*    createUrl: prefix + "/add",
                removeUrl: prefix + "/remove", */
                updateUrl: prefix + "/edit/{id}",
				exportUrl: prefix + "/export",
                modalName: "客户列",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'merchantNo', 
					title : '客户编号',
					sortable: true
				},
				{
					field : 'merchantCnName', 
					title : '客户名称',
					sortable: true
				},
				{
					field : 'agentNo', 
					title : '代理商编号',
					sortable: false
				},
				{
					field : 'agentName', 
					title : '代理名称',
					sortable: false
				},
				
				{
					field : 'parentName', 
					title : '推荐人',
					sortable: false
				},
				{
					field : 'parentPhone', 
					title : '推荐人手机号码',
					sortable: true
				},
				
				{
					field : 'phone', 
					title : '手机号',
					sortable: true
				},
				{
					field : 'level', 
					title : '客户等级',
					align : 'left',
					formatter: function(value, row, index) {
	            		return $.table.selectDictLabel(level, value);
	            	}
				},
				{
					field : 'liveness', 
					title : '活跃度',
					sortable: false
				},
				{
					field : 'creditRate', 
					title : '交易金额',
					sortable: false
				},
				{
					field : 'bankAccount', 
					title : '银行卡号',
					sortable: true
				},
				{
					field : 'bankName', 
					title : '银行名称',
					sortable: false
				},
				{
					field : 'submitExamineTime', 
					title : '升级黄金会员时间',
					sortable: true
				},
				{
					field : 'submitReexamineTime', 
					title : '升级经理时间',
					sortable: true
				},
				
				{
					field : 'idCardNumber', 
					title : '身份证',
					sortable: true
				},
				
				{
					field : 'upgradeCodeNum', 
					title : '升级码数量',
					sortable: true
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
				{
					field : 'id', 
					title : '客户id',
					visible: true
					
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	if (row.useStatus == "10A"){
		            	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')">变更客户信息</a> ');
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="forbidden(\'' + row.id + '\')">禁用客户账号</a> ');
		            	actions.push('<a class="btn btn-warning btn-xs  href="#" onclick="checkMoney(\'' + row.id + '\')">清账对账</a> ');
		            	} else{
		            	actions.push('<a class="btn btn-warning btn-xs ' + editFlag + '" href="#" onclick="opens(\'' + row.id + '\')">开启</a> ');
		            	}
						return actions.join('');
		            }
		        }]
            };

            $.table.init(options);
        });
        
        /* 客户状态-禁用 */
    	function forbidden(merchantId) {
    		$.modal.confirm("确认要禁用该客户？", function() {
    			$.operate.post(prefix + "/changeStatus", { "merchantId": merchantId });
    		   })
    	}
    	 /* 客户状态-开启*/
    	function opens(merchantId) {
    		$.modal.confirm("确认要开启该客户？", function() {
    			$.operate.post(prefix + "/changeStatus", { "merchantId": merchantId });
    		   })
    	}
    	 
    	 /* 清账对账*/
    	function checkMoney(id) {
    		$.modal.confirm("确认要核对清账？", function() {
    			 $.ajax({
    					url : prefix + "/checkMoney",
    					type : "POST",
    					data: {
    						"id":id
    					},
    					success : function(re) {
    						if (re.status == "SUCCESS") {
    							$.modal.msgSuccess(re.msg);
    						} else {
    							$.modal.msgError(re.msg);
    						}
    					}
    				}); 
    		   })
    	};
    	 
    	 
    	 
    </script>
</body>
</html>